<template>
	<div>
	<div v-show="!addFactoryUser" class="" style="width: 100%;height: 100%; position:fixed;left:0;top:0;background-color: rgba(0,0,0,0.1);display: flex;justify-content: center;align-items: center;z-index: 350;">
		<mu-circular-progress :size="24" color="green500"/>
	</div>
	<div v-show="addFactoryUser">
			<section style="width: 100%;justify-content: center;align-items: center;display: flex;">
			<section style="width: 60%;display: flex;flex-direction: column;">
				<section>{{factory.factoryname}}</section>
				
				
				<mu-text-field v-model="userName" placeholder="请输入用户名"></mu-text-field>
			  	<div class="aboutpass">
					<mu-text-field v-model="password" placeholder="请输入用户密码" v-if="ifDisplay" type="password" ></mu-text-field>
					<mu-text-field v-model="password" placeholder="请输入用户密码" v-else type="text"></mu-text-field>		  	
			  	  <span v-show="ifDisplay" @click="ifDisplay=!ifDisplay">显示密码</span>
			  	  <span v-show="!ifDisplay" @click="ifDisplay=!ifDisplay">隐藏密码</span>
			  	 </div>  	
			  	<section style="margin-top: 2rem;display: flex;justify-content: center;justify-content:space-between;align-items: center;flex-direction: row;" >
			  		
					<mu-button  @click="gotoAddress('factoryList')">返回</mu-button>
					<mu-button color="primary"  @click="BindNewServer()">绑定</mu-button>
				</section>
			  	 
			</section>
			
			
		</section>
	</div>
	</div>
</template>

<script>
	export default {
		data(){
			return{
				addFactoryUser:false,
				 factoryId: '',
				userName:'',
				password:'',
				confirmPassword:'',
				factory:null,
				psd:'',
				ifDisplay:false
			}
		},
		 mounted(){
			//获取版本号注释登录
				let that=this
	      		console.info('登录了')
				console.info(this.global.homeSrc)
	      		localStorage.token= this.$route.query.token
				let factoryId= this.$route.query.factoryId
//	      	localStorage.token='832c6f99275d5f201424e6e65443f160'
	      		that.axios.post(that.global.homeSrc+'Login/tokenLogin',{
	      			'token':localStorage.token,
	      		}).then(function(response){
					if(response.data.erroInfo=='success'){
                        localStorage.userNumber=response.data.uid           			
						console.info('zou')
						if(factoryId!=null){
							that.axios.post(that.global.homeSrc+'factoryUser/getFactoryUserById',{
								'factoryId':factoryId
						}).then(function(response){
								console.log(response)
								let factoryUser=response.data.factoryUser
								that.factory=response.data.factory
								if(factoryUser!=null){
								setTimeout(function(){
										that.$router.push(
										{
											'path':factoryUser.router,
											'name':factoryUser.router,
											params: { 
										         factoryId:factoryUser.factoryId,
										         factoryName:factoryUser.factoryName
										     }})
									},1480)
									
								}else{
									that.addFactoryUser=true
								}
								
						})
							
							

							
						}else{
							setTimeout(function(){
								
								
								
								
								that.$router.push(
								{
									path:'index',
									name:'index'
								})
							},1480)
							
						}
	           		}else if(response.data.erroInfo=='登录失败'){
						that.$toast.error('登录失败');
	           			console.info(response.data.erroInfo)
	           		}
	      		}).catch(function(error){
	      			 console.log(error)
					 that.$toast.error('登录失败，请重新登录');
	      			 console.log('失败')
	      		})
  		},
  		methods:{
			gotoAddress(path){
				var self=this
				setTimeout(function(){
					self.$router.push(path)
				},200)
	      	}
		}
	}
	
</script>

<style>
</style>